'This code is from a "registry wizard" application I am working on. It is used to perform tasks such as hide/unhide desktop icons,remove favorites menu from the start menu and disable the shut down windows option.(I will be adding some more options ASAP.)

'Copy the declarations and code below and paste directly into your VB project.

'Declarations:

 Option Explicit
   Dim msg As String
   Private Const REG_DWORD As Long = 4
   Private Const HKEY_CURRENT_USER = &H80000001
   Private Const KEY_ALL_ACCESS = &H3F
   Private Const REG_OPTION_NON_VOLATILE = 0

   Private Declare Function RegCloseKey Lib "advapi32.dll" _
   (ByVal hKey As Long) As Long
        
   Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey _
As String, _ByVal ulOptions As Long, ByVal samDesired As Long,_ phkResult As Long) As Long
      
Private Declare Function RegSetValueExLong Lib _
"advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long,_
ByVal lpValueName As String,ByVal Reserved As Long, _
ByVal dwType As Long, lpValue As Long,ByVal cbData As Long) As Long

'Code:

 'This is to remove the favorites menu from Start menu

Private Sub cmdfav_Click()
SetKeyValue "Software\Microsoft\Windows\Currentversion\policies\explorer", "NoFavoritesMenu", 1, REG_DWORD
msg = MsgBox("You need to restart Windows for the changes to take place.", vbCritical, "Restart Windows")
End Sub

'This is to hide the desktop icons

Private Sub cmdhide_Click()
SetKeyValue "Software\Microsoft\Windows\Currentversion\policies\explorer", "NoDesktop", 1, REG_DWORD
msg = MsgBox("You need to restart Windows for the changes to take place.", vbCritical, "Restart Windows")
End Sub

'This is to disable the shut down windows option

Private Sub cmdshut_Click()
SetKeyValue "Software\Microsoft\Windows\Currentversion\policies\explorer", "NoClose", 1, REG_DWORD
msg = MsgBox("You need to restart Windows for the changes to take place.", vbCritical, "Restart Windows")
End Sub

'This is to unhide the desktop icons

Private Sub cmdunhide_Click()
SetKeyValue "Software\Microsoft\Windows\Currentversion\policies\explorer", "NoDesktop", 0, REG_DWORD
msg = MsgBox("You need to restart Windows for the changes to take place.", vbCritical, "Restart Windows")
End Sub



Public Function SetValueEx(ByVal hKey As Long, sValueName As String,lType As Long, vValue As Variant) As Long
       Dim lValue As Long
       Dim sValue As String
       Select Case lType
          Case REG_DWORD
          lValue = vValue
          SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, _
   lType, lValue, 4)
      End Select
End Function

Private Sub SetKeyValue(sKeyName As String, sValueName As String,vValueSetting As Variant, lValueType As Long)
       Dim lRetVal As Long 
       Dim hKey As Long    
       lRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0, _
                              KEY_ALL_ACCESS, hKey)
       lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)
       RegCloseKey (hKey)
End Sub

